﻿using System;
using System.Windows;

namespace Client {
    class CircleBallViewModel : ViewModelBase {

        private int totalCount = 0;
        public int TotalCount {
            get { return totalCount; }
            set {
                totalCount = value;
                RaisePropertyChanged("TotalCount");
            }
        }
        private int loadedCount = 0;
        public int LoadedCount {
            get { return loadedCount; }
            set {
                loadedCount = value;
                RaisePropertyChanged("LoadedCount");
                TaskCount = TotalCount - LoadedCount;
                try {
                    Progress = $"{Math.Round(LoadedCount * 100 / (double)TotalCount)}%";
                } catch (Exception) {
                    Progress = "0%";
                }
            }
        }

        private string progress = "0%";
        public string Progress {
            get { return progress; }
            set {
                progress = value;
                RaisePropertyChanged("Progress");
            }
        }

        private bool isRun = false;
        public bool IsRun {
            get { return isRun; }
            set {
                isRun = value;
                RaisePropertyChanged("IsRun");
            }
        }

        private int taskCount;
        public int TaskCount {
            get { return taskCount; }
            set {
                taskCount = value;
                RaisePropertyChanged("TaskCount");
                if (taskCount > 0) {
                    ShowRedPoint = Visibility.Visible;
                    IsRun = true;
                } else {
                    ShowRedPoint = Visibility.Hidden;
                    IsRun = false;
                }
            }
        }

        private Visibility showRedPoint = Visibility.Hidden;
        public Visibility ShowRedPoint {
            get { return showRedPoint; }
            set {
                showRedPoint = value;
                RaisePropertyChanged("ShowRedPoint");
            }
        }

    }
}
